#include "stm32f10x.h"
#include "./usart/usart.h"
#include "./oled_iic/oled_iic.h"
#include "./delay/delay.h"
#include "./key/key.h"
#include "./sdio/sdio_sdcard.h"
#include "./FatFs/ff.h"
/**
  * @brief  主函数
  * @param  无
  * @retval 无
  */
int main(void)
{	
	int key_i,led_i=0,led_n=0;
	
	SystemInit();
	/*初始化USART1 / USART2 配置模式为 115200 8-N-1，中断接收*/
	USART_Config();
	
	//系统初始化
	Usart_SendString(DEBUG_USARTx, "系统时初始化\n");
	//延时初始化
	DelayInit();
	Usart_SendString(DEBUG_USARTx, "延时初始化 -- 完成\n");
	
	//按键初始化
	Key_Init();
	Usart_SendString(DEBUG_USARTx, "按键初始化 -- 完成\n");
	
	//OLED屏幕初始化
	I2C_Configuration();
	OLED_Init();
	OLED_CLS();
	OLED_ShowStr(24,0,(unsigned char*)"Hello World!",1);
	OLED_ShowStr(15,1,(unsigned char*)"Hello World!",2);
	Usart_SendString(DEBUG_USARTx, (char *)"Oled初始化 -- 完成\n");
	
	SdCard_Init();
	
	while(1)
	{
		for(key_i=1;key_i<=5;key_i++)
		{
			if(!Key_Get(key_i))
				break;
		}
		
		if(key_i != 6)
			OLED_ShowStr(35,4,(unsigned char*)"Key_get",1);
		else
			OLED_ShowStr(35,4,(unsigned char*)".......",1);
		led_n += 1;
		if(led_n>=10)
		{
			if(led_i==0)
				led_i=1;
			else
				led_i=0;
			Led_Set(led_i);
			led_n = 0;
		}
		DelayMs(50);
	}
}
/*********************************************END OF FILE**********************/
